package com.zhtkj.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;

/** 
* @ClassName: SpringHolder 
* @Description: spring相关操作类 
* @author mafeng 
* @date 2017年9月7日 上午9:51:08 
*  
*/
public class SpringHolder {

	//spring应用上下文
    private static AbstractApplicationContext applicationContext;  
    
	private SpringHolder() {
		
	}
    
    public static void setApplicationContext(AbstractApplicationContext appCtx) {  
        applicationContext = appCtx;  
    }
    
    public static ApplicationContext getApplicationContext() {  
        return applicationContext;  
    }  
  
    /** 
    * @Title: getBean 
    * @Description: 根据bean名称获取bean 
    * @param: @param name
    * @param: @return 
    * @return Object 
    * @throws 
    */
    public static Object getBean(String name) {  
        return getApplicationContext().getBean(name);  
    }
	
}
